<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <link REL="SHORTCUT ICON" HREF="http://www.example.org/myicon.ico" type="image/x-icon"/>
    <link REL="SHORTCUT" HREF="http://www.example.org/myicon.ico" type="image/x-icon"/>
    <title>Homework. Add new text file to database.</title>
</head>
<body>
    <p><span>Enter file name:</span></p>
	<p><input id="userInput" type="text" name="file"></p>
    <p><input type="submit" onclick="send(this)"></p>
	<span name="Output" id="Output"></span>
	<script language="JavaScript" type="text/javascript">
		var http_request = false;

		function makePOSTRequest(url, parameters) {
		  http_request = false;
		  if (window.XMLHttpRequest) { // Mozilla, Safari,...
		    http_request = new XMLHttpRequest();
		    if (http_request.overrideMimeType) {
		      http_request.overrideMimeType('text/html');
		    }
		  } else if (window.ActiveXObject) { // IE
		    try {
		      http_request = new ActiveXObject("Msxml2.XMLHTTP");
		    } catch (e) {
		      try {
		        http_request = new ActiveXObject("Microsoft.XMLHTTP");
		      } catch (e) {}
		    }
		  }
		  if (!http_request) {
		    document.getElementById('Output').innerHTML = "Cannot create XMLHTTP instance";
		    return false;
		  }
		  http_request.onreadystatechange = function() {
            alertContents(http_request);
        };
		  http_request.open('GET', url, true);
		  http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		  http_request.setRequestHeader("Content-length", parameters.length);
		  http_request.setRequestHeader("Connection", "close");
		  http_request.send(parameters);
		}

		function alertContents(httpRequest) {
		  if (httpRequest.readyState == 4) {
		    if (http_request.status == 200) {
		      result = httpRequest.responseText;
		      document.getElementById('Output').innerHTML = result;
		    } else {
		      document.getElementById('Output').innerHTML = "There was a problem with the request.";
		    }
		  }
		}

		function send(obj) {
		  var poststr = "uri=" + encodeURI( document.getElementById("userInput").value );
		  makePOSTRequest('http://localhost:8080/' + poststr, poststr);
		}

		document.getElementById('userInput').value="../input/kipling.txt";

	</script>
</body>
</html>
